import React, { useEffect, useState } from 'react'
import request from './request'
export default function App() {
    let [sentence, setSentence] = useState('')
    // componentDidMount
    useEffect(() => {
        // useEffect 的回调函数不能使用async修饰，如果要做异步，写法如下，定义一个async函数，手动调用
        async function getSentence() {
            let res = await request.get('/hitokoto/get', {
                params: {
                    type: 'social'
                }
            })
            setSentence(res)
        }
        getSentence()
    }, [])
    return (
        <div>
            <h3>名言警句: {sentence}</h3>
        </div>
    )
}
